<template>
	<view class="menberCenter">
		<view class="topBox">
			<image :src="imaurl+'c6.png'" style="width: 100%;height: 588rpx;" mode="" @click="handleBack">
			</image>
			<view class="contentBox">
				<view class="navbarBox">
					<!-- <image src="../../../static/image/c7.png" style="width: 48rpx;height: 48rpx;" mode=""></image>
					<view class="text">
						会员中心
					</view> -->
					<u-navbar title="会员中心" @leftClick="leftClick" :autoBack="true" :bgColor='bgColor'
						:titleStyle='titleStyle' leftIconColor="#ffffff">
					</u-navbar>
				</view>

				<view class="userInfo">
					<image :src="userInfo.avatar" style="width: 80rpx;height: 80rpx;border-radius: 80rpx;" mode="">
					</image>
					<view class="nikeName" style="margin: 0 20rpx;">
						{{userInfo.nickname}}
					</view>
					<view v-if="userInfo.is_vip==0" class="status">
						未开通
					</view>
					<view v-else class="">
						<image :src="imaurl+'c10.png'" style="width: 40rpx;height: 40rpx;margin-left: 10rpx;" mode="">
						</image>
					</view>

				</view>
				<view class="by">
					开通至尊会员
				</view>
				<view class="bys">
					专项会员权益
				</view>
			</view>
		</view>


		<view class="titleBox">
			<view class="shu"></view>
			<view class="">
				会员权益
			</view>
		</view>

		<view class="serveList">
			<view class="serveItem" v-for="(item,index) in vipServe">
				<image :src="item.image" style="width: 80rpx;height: 80rpx;" mode=""></image>
				<view class="right">
					<view class="name">
						{{item.name}}
					</view>
					<view class="desc">
						{{item.info}}
					</view>
				</view>
			</view>
			<!-- 	<view class="heng"></view>
			<view class="serveItem">
				<image src="@/static/image/b5.png" style="width: 80rpx;height: 80rpx;" mode=""></image>
				<view class="right">
					<view class="name">
						免费菌群检测
					</view>
					<view class="desc">
						这里是权益介绍，这里是权益介绍这里是权益介绍这里是权益介绍
					</view>
				</view>
			</view> -->
			<!-- <view class="heng"></view>
			<view class="serveItem">
				<image src="@/static/image/b6.png" style="width: 80rpx;height: 80rpx;" mode=""></image>
				<view class="right">
					<view class="name">
						DNA检测3次
					</view>
					<view class="desc">
						这里是权益介绍这里是权益介绍这里是权益介绍
					</view>
				</view>
			</view> -->
			<!-- <view class="heng"></view>
			<view class="serveItem">
				<image src="@/static/image/c8.png" style="width: 80rpx;height: 80rpx;" mode=""></image>
				<view class="right">
					<view class="name">
						飞行力检测3次
					</view>
					<view class="desc">
						这里是权益介绍这里是权益介绍这里是权益介绍
					</view>
				</view>
			</view> -->
		</view>


		<view class="btns" @click="handleOpenvip">
			￥{{sumprice}} 立即开通
		</view>


	</view>
</template>

<script>
	import {
		vipcontent,
		openvip
	} from "@/api/api.js"
	export default {
		data() {
			return {
				bgColor: 'transparent',
				titleStyle: {
					'color': '#ffffff !important',
				},
				userInfo: {},
				vipServe: [],
				imaurl: "https://szgb.tongchengbang.cc/img/image/",
				sumprice: "",
			}
		},
		onLoad() {
			this.handlevipcontent()
		},
		methods: {
			async handlevipcontent() {
				let res = await vipcontent()
				this.userInfo = res.data.userinfo
				this.vipServe = res.data.vip_privilege
				this.sumprice = res.data.vip_price
			},
			leftClick() {},
			async handleOpenvip() {
				let res = await openvip()
				if (res.code == 1) {
					uni.requestPayment({
						provider: 'wxpay',
						appId: res.data.appId,
						timeStamp: res.data.timeStamp,
						nonceStr: res.data.nonceStr,
						package: res.data.package,
						signType: res.data.signType,
						paySign: res.data.paySign,
						success(res) {
							console.log("支付成功、、、、、、、、、、、、、、、、")
							uni.showToast({
								title: res.msg,
								icon: "none",
								duration: 2000
							});
							setTimeout(() => {
								this.handlevipcontent()
							}, 2100)
						},
						fail(e) {}
					})

				} else {
					uni.showToast({
						title: res.msg,
						icon: "none",
						duration: 2000
					});
				}
			},
			handleBack() {
				console.log("3333333")
				uni.navigateBack({
					delta: 1
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.menberCenter {
		width: 100%;
		min-height: 100%;
		background-color: #ffffff;
		background-color: transparent;

		.topBox {
			width: 100%;
			position: relative;

			.contentBox {
				width: 100%;
				height: 588rpx;
				position: absolute;
				top: 0;
				padding-top: 88rpx;
				box-sizing: border-box;

				.navbarBox {
					display: flex;
					align-items: center;
					width: 750rpx;
					height: 88rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 32rpx;
					color: #FFFFFF;
					line-height: 38rpx;
					text-align: center;
					padding: 30rpx;
					box-sizing: border-box;
					z-index: 999;

					.text {
						margin-left: 232rpx;
					}

				}

				.userInfo {
					margin-top: 30rpx;
					display: flex;
					align-items: center;
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 32rpx;
					color: #FFFFFF;
					line-height: 38rpx;
					width: 100%;
					padding-left: 40rpx;

					.status {
						width: 88rpx;
						height: 34rpx;
						border-radius: 8rpx 8rpx 8rpx 8rpx;
						border: 1rpx solid #888888;
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						font-size: 24rpx;
						color: #888888;
						line-height: 34rpx;
						text-align: center;
					}
				}

				.by {
					font-family: PingFang SC, PingFang SC;
					font-weight: 800;
					font-size: 36rpx;
					color: #E6BE91;
					line-height: 42rpx;
					margin-top: 90rpx;
					margin-left: 80rpx;
				}

				.bys {
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #FFFFFF;
					line-height: 33rpx;
					margin-top: 20rpx;
					margin-left: 80rpx;
				}

			}

		}

		.titleBox {
			font-family: PingFang SC, PingFang SC;
			font-weight: 800;
			font-size: 32rpx;
			color: #333333;
			line-height: 38rpx;
			display: flex;
			align-items: center;
			margin-left: 40rpx;

			.shu {
				width: 8rpx;
				height: 32rpx;
				background: #00BF52;
				border-radius: 200rpx 200rpx 200rpx 200rpx;
				margin-right: 20rpx;
			}
		}

		.serveList {
			margin-top: 40rpx;

			.serveItem {
				display: flex;
				align-items: center;
				padding: 30rpx;
				box-sizing: border-box;

				.right {
					width: 570rpx;
					margin-left: 16rpx;

					.name {
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						font-size: 32rpx;
						color: #333333;
						line-height: 38rpx;
					}

					.desc {
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						font-size: 24rpx;
						color: #666666;
						line-height: 28rpx;
						margin-top: 10rpx;
					}
				}
			}

			.heng {
				width: 570rpx;
				height: 1rpx;
				background-color: #F6F6F6;
				margin-left: 140rpx;
			}
		}


		.btns {
			width: 630rpx;
			height: 88rpx;
			background: #00BF52;
			border-radius: 200rpx 200rpx 200rpx 200rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			font-size: 32rpx;
			color: #FFFFFF;
			line-height: 88rpx;
			text-align: center;
			position: absolute;
			bottom: 120rpx;
			left: 50%;
			margin-left: -315rpx;
		}

	}
</style>